# -*- coding: utf-8 -*-

import prettytable as pt


class PrintStaffBase(object):
    """格式化输出类，输出为表格样式"""

    def __init__(self):
        self.tb = pt.PrettyTable()
        self.tb.field_names = ['姓名', '工号', '入职时间', '部门', '职位']

    @staticmethod
    def _get_staff_details(staff):
        staff_details = [staff['name'], staff['id'], staff['entry_date'],
                         staff['department'], staff['position']]
        return staff_details

    def print_staff(self, staffs):
        if isinstance(staffs, list):
            for staff in staffs:
                staff_details = self._get_staff_details(staff)
                self.tb.add_row(staff_details)
        else:
            staff_details = self._get_staff_details(staffs)
            self.tb.add_row(staff_details)

        return self.tb
